home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / resetsw.arc / RAMDISK.TXT < prev    next >
Encoding:
Text File  |  1986-01-05  |  9.9 KB  |  188 lines

  1.                        High Memory RAMDisk
  2.  
  3.      The following letter from Skip Chambers, Carrollton, TX, along
  4. with the editor's (C. Petzold) remarks appeared in the Power User
  5. column of PC Magazine, Vol 4 No 21 October 15, 1985.
  6.  
  7.      Here's the secret for installing 128K additional RAM in the IBM PC
  8. and XT, over and above the normal 640K limit.  The added memory can be
  9. used for a RAMdisk.
  10.      The first step is to install 128K RAM in a standard IBM 64/256K
  11. Memory Expansion Option board.  Set the DIP switches thus:
  12.  
  13.           1    2    3    4    5    6    7    8
  14.          OFF  OFF  ON   OFF  OFF  ON   OFF  OFF
  15.  
  16. This configures the board for 128K at segment address D000h and E000h.
  17.      Next, you must modify the DOS 2.0/2.1 RAMdisk program to use this
  18. extra memory rather than normal user RAM.  Since a manual reboot will
  19. not clear out this memory, I've provided some additional code to retain
  20. the contents of the RAMdisk and not reinitialize it if a manual reboot
  21. is in progress.
  22.                                              Skip Chambers
  23.  
  24. Editor's Remarks:
  25.  
  26.      Although this extra memory space cannot normally be recognized by
  27. programs running under DOS, as alternatives to using it for a RAMdisk,
  28. you could also use it for a print buffer or as a BLOAD area to hold
  29. machine language subroutines under BASIC.
  30.      I find this very exciting.  Until recently, I have used a 160K
  31. RAMdisk, mostly for WordStar.  But what with the size of DOS 3.1 and an
  32. AUTOEXEC full of remain-resident programs, I gobble up 128K at boot
  33. time.  In order to run programs requiring 512K, I had to give up my
  34. RAMdisk.  Now I've got one back.
  35.      Although the RAMdisk program we'll be modifying is taken from the
  36. DOS 2.x manuals, the changes work both under DOS 2.x and 3.x.
  37.      Let's step back a minute to see why this trick is so neat.
  38.      The 8088 microprocessor used in the IBM PC and PC-XT can directly
  39. address 1,048,576 bytes of memoty or 1,024K.  But only the first 640K
  40. is allocated for random-access (or user) memory.  The other 384K is
  41. reserved by IBM for other purposes.
  42.      At the very top of memory, 64K is allocated for the ROM BIOS and
  43. ROM BASIC interpreter.  Just above the 640K random-access memory, 128K
  44. is reserved for video display memory.  While the monochrome display
  45. actually requires only 4K and the standard color/graphics display uses
  46. only 16K of this 128K reserved area, the IBM Enhanced Graphics Adapter
  47. (EGA) lays claim to much more of it.
  48.      Following the video display memory is 64K for additional ROMs,
  49. such as those containing the BIOS support for the PC-XT hard disk and
  50. the EGA.
  51.      This leaves another 128K, which IBM allocated for additional ROM
  52. expansion and which is, indeed, the memory area used for PCjr ROM
  53. cartridges.  But on the PC and PC-XT, this area will normally be free
  54. for you to install another random-access memory board.  If you have a
  55. non-IBM hard disk or other heavy hardware in your system, however, you
  56. must check to see if it addresses ROM segments D000h or E000h.  If so,
  57. you're already using this area, and so you won't be able to install the
  58. additional memory described here.
  59.      You'll also need a memory board that can be switched to segments
  60. D000h and E000h.  Some multifunction boards -- the popular AST Six-Pak-
  61. Plux, for instance -- cannot themselves be switched to address an area
  62. above 640K.  However, if you're up to 640K, you probably already have
  63. a multifunction board, so a straight memory board such as the IBM
  64. 64/256K Memory Expansion Option is ideal.
  65.      To install a 128K RAMdisk at this address, you'll also need either
  66. the DOS 2.0 or 2.1 Technical Reference manual (the IBM RAMdisk program
  67. is found at the end of the chapter on device drivers), plus a macro
  68. assembler, such as those from IBM or Microsoft.
  69.      Type in the "Sample Device Driver" program, calling the file
  70. EDISK.ASM.  (EDISK stands for "Extra Memory Disk.")  Do not type the
  71. numbers on the left side of the IBM listing: enter only that part of
  72. each line that is even with the top-most semicolon.  Further, do not
  73. type in any of the lines that have a plus sign just to the left of
  74. them (they're toward the end of the listing).  These are lines created
  75. by teh assembler when expanding the macros.
  76.      Assemble, ling, and convert your EDISK.ASM into a .SYS file by
  77. using the following commands:
  78.  
  79.           MASM EDISK,,;
  80.           LINK EDISK;
  81.           EXE2BIN EDISK EDISK.SYS
  82.  
  83.      Success means getting only one error message from MASM, namely,
  84. that there is no stack segment.  Ignore it.  MASM will also create a
  85. file called EDISK.LST.  To assure yourself that you typed the program
  86. in correctly, check the addresses and assembled machine code at the
  87. left of the EDISK.LST listing with the program listing in the DOS
  88. manual.
  89.      The next step is to include a line in a CONFIG.SYS file in the
  90. root directory of your boot disk.  This line is:  DEVICE=EDISK.SYS.
  91. EDISK will then be loaded at boot time.  When first installing a
  92. device driver such as EDICK, you should have two different ways to
  93. boot your system (such as a disk without EDISK and a disk with EDISK),
  94. because if errors in the EDISK program crash your system, you need some
  95. way of booting without it.
  96.      Unmodified, EDISK.SYS simply creates a 180K RAMdisk on your system
  97. in regular user memory.  This disk will have a drive letter one above
  98. your normal drive.  You may use this disk like any other except that
  99. the contents will be destroyed if the PC is turned off or if you
  100. reboot.
  101.      Figures 1 through 4 show the changes to make in EDISK.ASM so that
  102. it will use the extra random-access memory at segments D000h and E000h.
  103. The line numbers are consistent with the line numbers in the DOS 2.0
  104. and 2.1 manuals.  Line numbers with decimals, such as 230.1, are
  105. insertions; that line would go between line 230 and 231.  Otherwise,
  106. the lines replace those in the DOS 2.x program.
  107.      Figure 1 shows a few changes you should make even if you only want
  108. to set up a normal IBM RAMdisk.  These changes take care of the most
  109. blatant bugs and allow the program to be assembled under later versions
  110. of the IBM or Microsoft Macro Assembler.
  111.      Figure 2 shows the changes used to shorten the RAMdisk to 256
  112. sectors and to place it at segment addresses D000h and E000h.  Each
  113. sector is 512 bytes, so total disk space will be reduced from IBM's
  114. 180K to the 128K you have available.
  115.      This is really all that's needed, but you might be in for a
  116. surprise if you read some RAMdisk sectors directly from DEBUG or run
  117. Norton Utilities DISKTEST program on the new RAMdisk.  You'll probably
  118. get a parity check error, since the added memory was not properly
  119. initialized by the BIOS during boot time.  Initialization is easy,
  120. however: all you do is write something to it.  Figure 3 shows the
  121. added steps to initialize the new memory properly.
  122.      Figure 4 shows the additions to preserve the disk contents
  123. during a "warm boot."  Turning on the PC's switch is sometimes called
  124. a cold start; resetting the computer with the Ctrl-Alt-Del key
  125. sequence represents a hot (or warm) start.  The code shown in Figure 4
  126. preserves the contents of the disk when you use a keyboard reset,
  127. though they will be lost, of course, if you turn the machine off with
  128. the power switch.
  129.      By the way, you should not study the RAMdisk program in the DOS
  130. 2.x manual in hopes of learning good assembler programming practice!
  131. The listing is excessively macroed and equated to the point where it
  132. is virtually unreadable.  Moreover, the most important types of
  133. equates -- those that would allow the user to change the number of
  134. sectors or the sector size with one statement at the top of the
  135. program -- are missing.
  136. - - - - -
  137. Figure 1:
  138.  
  139. 102       USER_DTA  DW   ?,?                 ;CORRECTION
  140. 230.1               PUSH CS                  ;ADDITION
  141. 230.2               POP  DS                  ;ADDITION
  142. 230.3               LES  BX,DWORD PTR RH_OFF ;ADDITION
  143. - - - - -
  144. Figure 2:
  145.  
  146.  92                 DW   256                 ;TOTAL NUMBER OF SECTORS
  147. 115                 DW   256                 ;TOTAL NUMBER OF SECTORS
  148. 247                 MOV  CS:VDISK_PTR,0D000H ;RAM DISK SEGMENT
  149. 248                                          ;DELETE LINE
  150. 249                                          ;DELETE LINE
  151. - - - - -
  152. Figure 3:
  153.  
  154. 257.1               MOV  CX,8000H            ;NUMBER OF BYTES
  155. 257.2               SUB  AX,AX               ;BYTE TO WRITE
  156. 257.3               REP  STOSW               ;1ST SEGMENT DONE
  157. 257.4               MOV  CX,ES               ;ES TO NEXT SEGMENT
  158. 257.5               ADD  CX,1000H
  159. 257.6               MOV  ES,CX
  160. 257.7               MOV  CX,8000H            ;NUMBER OF BYTES
  161. 257.8               REP  STOSW               ;2ND SEGMENT DONE
  162. 257.9               MOV  ES,CS:VDISK_PTR     ;BACK TO 1ST SEGMENT
  163. - - - - -
  164.  
  165.  
  166. Figure 4:
  167.  
  168. 255.1               PUSH DS             ;SAVE DS
  169. 255.2               MOV  AX,40H         ;BIOS DATA SEGMENT
  170. 255.3               MOV  DS,AX          ;SET UP SEGMENT REGISTER
  171. 255.4               CMP  WORD PTR DS:[0072H],1234H
  172. 255.5               POP  DS             ;CHECK RESET MODE
  173. 255.6               JNZ  COLD_START     ;INITIALIZE DISK
  174. 255.7               JMP  HOT_START      ;SKIP IF KEYBOARD RESET
  175. 255.8     COLD_START:
  176.  
  177.  
  178. 290.1               LEA  DX,COLD_MSG
  179. 290.2               JMP  SHORT MESSAGE
  180. 290.3     COLD_MSG  DB   13,10,"Hi-RAM disk installed.",13,10,"$"
  181. 290.4     HOT_MSG   DB   13,10,"Hi-RAM disk preserved.",13,10,"$"
  182. 290.5     HOT_START:LEA  DX,HOT_MSG     ;MESSAGE TO PRINT
  183. 290.6     MESSAGE:  PUSH CS             ;CURRENT SEGMENT
  184. 290.7               POP  DS             ;SET DS TO IT
  185. 290.8               MOV  AH,9           ;DOS PRINT STRING CALL
  186. 290.9               INT  21H            ;PRINT STRING
  187.  
  188.